#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

class Solution
{
public:
    int halveArray(vector<int>& nums)
    {
        priority_queue<double> heap;
        double num = 0.0;
        for (auto& ch : nums)
        {
            num += ch;
            heap.push(ch);
        }
        double half = num / 2;
        int ret = 0;
        double tp = 0;
        do
        {
            ret++;
            tp = heap.top();
            heap.pop();
            num -= tp / 2;
            heap.push(tp / 2);
        } while (num > half);
        return ret;
    }
};